<include file="common/header_dc" title="{$title}" body=""/>
<div class="page">
    <div class="page-hd">
        <div class="header">
            <div class="header-left">
                <a href="javascript:history.go(-1)" class="left-arrow"></a>
            </div>
            <div class="header-title">{$title}</div>
            <div class="header-right">
                <a href="#"></a>
            </div>
        </div>
    </div>

    <div class="page-bd">
        <!-- 页面内容-->
        <form method="post" id="payform">
            <div class="weui-cells weui-cells_form">
                <input type="hidden" name="id" value="{$miner.miner_id}">
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">矿机</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" value="{$miner.miner_name}" readonly>
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">倍数</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" value="{$miner.multiple}" readonly>
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">最低购买</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" id="min" type="text" value="{$miner.min}" readonly>
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">最高购买</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" id="max" type="text" value="{$miner.max}" readonly>
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">购买量</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" id="miner_price" name="miner_price" placeholder="请输入购买量，纯数字" onkeyup = "value=value.replace(/[^\d]/g,'')">
                    </div>
                </div>
            </div>
            <div class="weui-btn-area">
                <a href="javascript:void(0);" style="background-image: linear-gradient(250deg, #e62e2e 0%, #e62e2e 100%), linear-gradient(#e62e2e, #e62e2e) !important;box-shadow: 0.033333rem 0.058rem 0.133333rem 0 rgba(157, 157, 157, 0.3);border-radius: 42px;font-size: 0.2rem;height: 0.6rem;line-height: 0.6rem;border: solid 0.006667rem #e62e2e;" class="weui-btn weui-btn_primary" onclick="submits()">升级</a>
            </div>
        </form>
    </div>
</div>
<script>
    $(function() {
        FastClick.attach(document.body);
    });
</script>
<script>
 //提交前验证表单
    function submits() {
        var miner_price = $('#miner_price').val();
        var min = $('#min').val();
        var max =  $('#max').val();
        /*if (miner_price == '') {
            showErrorMsg('请输入购买量');
            return false;
        }
        if (miner_price < min){
            showErrorMsg('购买量不得小于最小购买量！');
            return false;
        }
        alert(miner_price);alert(max);
        if (miner_price > max){
            showErrorMsg('购买量不得大于最大购买量！');
            return false;
        }*/
        $.ajax({
            url: "{:U('index/upgradeSubmit')}",
            type: 'post',
            dataType: 'json',
            data: $('#payform').serialize(),
            success: function (data) {
                if (data.code == 1) {
                    $.toast(data.msg, function() {
                        window.location.href = "{:U('Mining/my_mining')}";
                    });
                } else {
                    showErrorMsg(data.msg);
                    return false;
                }
            }
        })
    }
    /**
     * 提示弹窗
     * */
    function showErrorMsg(msg) {
        $.toast(msg,'cancel');
    }
    $(function () {
        FastClick.attach(document.body);
    });
</script>
</body>
</html>
